//
//  DCMyFriendTableViewCell.m
//  xmppBase
//
//  Created by striby on 16/1/7.
//  Copyright © 2016年 com.dc. All rights reserved.
//

#import "DCMyFriendTableViewCell.h"
@implementation DCMyFriendTableViewCell

- (void)awakeFromNib {
    // Initialization code
    
    
    [self.SelectStatus addTarget:self action:@selector(SelectBtnPressed:) forControlEvents:UIControlEventTouchUpInside];
}



-(void)setHidenSelectStatusBtn:(BOOL)isHiden
{
    
    
    
    if (isHiden) {
        self.SelectStatus.hidden=YES;
        
        NSArray * constraints = self.contentView.constraints;
        
        for (NSLayoutConstraint* constraint in constraints) {
            
            if ([constraint firstAttribute]==NSLayoutAttributeLeading)
            {
                constraint.constant=8;
            }
        }
        
        [self setNeedsLayout];
        [self layoutIfNeeded];
        
    }
    else
    {
        [self.SelectStatus setImage:[UIImage imageNamed:@"unselect"] forState:UIControlStateNormal];
    }
    
}





- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

-(void)ChangeCurrentBtnImage
{
    if (_isBtnSelected) {
        [self.SelectStatus setImage:[UIImage imageNamed:@"select"] forState:UIControlStateNormal];
    }
    else
    {
        [ self.SelectStatus setImage:[UIImage imageNamed:@"unselect"] forState:UIControlStateNormal];
    }
}

- (IBAction)SelectBtnPressed:(id)sender {
    
    if (!_isBtnSelected) {
        _isBtnSelected = YES;
        
        [self ChangeCurrentBtnImage];
    }
    else
    {
        _isBtnSelected=NO;
        
        [self ChangeCurrentBtnImage];
    }
    
    
    if (self.delegate) {
        if ([self.delegate respondsToSelector:@selector(friendCellSelectEventWithIndexPath:isSelected:)]) {
            [self.delegate friendCellSelectEventWithIndexPath:self.indexPath isSelected:_isBtnSelected];
        }
    }
    
    
}
@end

